﻿using Entities;
using Microsoft.EntityFrameworkCore;

namespace ProductService.Data;

public static class SeedData
{
    public static async Task InitializeAsync(ApplicationDbContext context)
    {
        await context.Database.MigrateAsync();
        
        var hasInit = await context.Set<Tag>().AnyAsync();
        
        if (!hasInit)
        {
            var tags = new List<Tag>
            {
                new Tag { 
                    Name = "编程开发", 
                    Slug = "programming", 
                    Desc = "编程开发相关技术文章"
                },
                new Tag { 
                    Name = "前端技术", 
                    Slug = "frontend", 
                    Desc = "前端开发技术和框架"
                },
                new Tag { 
                    Name = "后端开发", 
                    Slug = "backend", 
                    Desc = "服务器端开发技术"
                },
                new Tag { 
                    Name = "数据库", 
                    Slug = "database", 
                    Desc = "数据库管理和优化"
                },
                new Tag { 
                    Name = "人工智能", 
                    Slug = "ai", 
                    Desc = "人工智能和机器学习"
                },
                new Tag { 
                    Name = "大数据", 
                    Slug = "bigdata", 
                    Desc = "大数据处理和分析"
                },
                new Tag { 
                    Name = "云计算", 
                    Slug = "cloud", 
                    Desc = "云计算和分布式系统"
                },
                new Tag { 
                    Name = "DevOps", 
                    Slug = "devops", 
                    Desc = "开发和运维一体化"
                },
                new Tag { 
                    Name = "微服务", 
                    Slug = "microservices", 
                    Desc = "微服务架构设计"
                },
                new Tag { 
                    Name = "容器技术", 
                    Slug = "container", 
                    Desc = "Docker和容器化技术"
                },
                new Tag { 
                    Name = "网络安全", 
                    Slug = "cybersecurity", 
                    Desc = "网络和信息安全"
                },
                new Tag { 
                    Name = "移动开发", 
                    Slug = "mobile", 
                    Desc = "移动应用开发"
                },
                new Tag { 
                    Name = "用户体验", 
                    Slug = "ux", 
                    Desc = "用户体验设计"
                },
                new Tag { 
                    Name = "测试技术", 
                    Slug = "testing", 
                    Desc = "软件测试和质量保证"
                },
                new Tag { 
                    Name = "项目管理", 
                    Slug = "project-management", 
                    Desc = "项目管理和敏捷开发"
                },
                new Tag { 
                    Name = "区块链", 
                    Slug = "blockchain", 
                    Desc = "区块链技术和应用"
                },
                new Tag { 
                    Name = "物联网", 
                    Slug = "iot", 
                    Desc = "物联网技术和应用"
                },
                new Tag { 
                    Name = "游戏开发", 
                    Slug = "gamedev", 
                    Desc = "游戏开发和设计"
                },
                new Tag { 
                    Name = "开源技术", 
                    Slug = "opensource", 
                    Desc = "开源项目和技术"
                },
                new Tag { 
                    Name = "职业发展", 
                    Slug = "career", 
                    Desc = "程序员职业发展"
                }
            };

            await context.Set<Tag>().AddRangeAsync(tags);
            await context.SaveChangesAsync();
        }
    }
}